package cn.tedu.csmall.product.repository.impl;

import cn.tedu.csmall.commons.consts.JwtCacheConsts;
import cn.tedu.csmall.commons.pojo.po.AdminLoginInfoPo;
import cn.tedu.csmall.product.repository.IAdminJwtRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Repository;

import java.io.Serializable;

/**
 * 处理管理员数据缓存的访问实现类
 *
 * @author java@tedu.cn
 * @version 0.0.1
 */
@Repository
public class AdminJwtRepositoryImpl implements IAdminJwtRepository, JwtCacheConsts {

    @Autowired
    private RedisTemplate<String, Serializable> redisTemplate;

    @Override
    public AdminLoginInfoPo getLoginInfo(String jwt) {
        String key = ADMIN_JWT_PREFIX + jwt;
        Serializable serializable = redisTemplate.opsForValue().get(key);
        AdminLoginInfoPo adminLoginInfoPO = (AdminLoginInfoPo) serializable;
        return adminLoginInfoPO;
    }

}
